feat: update document index status model and related components#985
Conversation
iziang
commented
Jun 24, 2025
- Refactored document index status to use a single status model with new states: CREATING, ACTIVE, DELETING, and DELETION_IN_PROGRESS.
- Updated related database models, API components, and service logic to accommodate the new status model.
- Adjusted index management and reconciliation processes to align with the new status definitions.
- Modified tests to reflect changes in index status handling and ensure compatibility with the updated API responses.
- Refactored document index status to use a single status model with new states: CREATING, ACTIVE, DELETING, and DELETION_IN_PROGRESS. - Updated related database models, API components, and service logic to accommodate the new status model. - Adjusted index management and reconciliation processes to align with the new status definitions. - Modified tests to reflect changes in index status handling and ensure compatibility with the updated API responses.
- Introduced a new IndexAction class to standardize index operation types (CREATE, UPDATE, DELETE). - Updated DocumentIndexReconciler to utilize the new IndexAction constants for improved clarity and maintainability. - Refactored document deletion logic in DocumentService to streamline the deletion process and ensure proper index reconciliation. - Enhanced error handling and logging during document deletion and index management operations. - Updated documentation to reflect changes in the indexing architecture and operational flow.
🚨 BugBot couldn't runSomething went wrong. Try again by commenting "bugbot run", or contact support (requestId: serverGenReqId_8ad2d329-132f-4331-81eb-9e80d2d182ac). |
There was a problem hiding this comment.
Bug: Incorrect Return Type Causes Serialization Errors
The delete_document service method in aperag/service/document_service.py has an incorrect return type annotation (dict) and returns a raw database model (db_models.Document) instead of the expected view_models.Document. This creates a type mismatch with the delete_document_view API endpoint in aperag/views/main.py, which is annotated to return view_models.Document, leading to runtime serialization errors.
aperag/service/document_service.py#L288-L299
ApeRAG/aperag/service/document_service.py
Lines 288 to 299 in 8c580b6
aperag/views/main.py#L126-L135
Lines 126 to 135 in 8c580b6
Bug: Incorrect Return Type Causes Serialization Errors
The delete_document method's signature declares a dict return type, but it incorrectly returns a db_models.Document object. This returned object is problematic as it has just been deleted from the session, making it detached and potentially unusable. This type inconsistency will cause serialization errors in the API response, which expects a view_models.Document or a dict. The previous implementation correctly converted the database model to a view model before returning.
aperag/service/document_service.py#L282-L299
ApeRAG/aperag/service/document_service.py
Lines 282 to 299 in 8c580b6
Was this report helpful? Give feedback by reacting with 👍 or 👎